/**
 * @Author: lclangcheng
 * @Date:   2018-08-17 10:28:35
 * @Email:  lclangcheng@gmail.com
 * @Filename: index.js
 * @Last modified by:   lclangcheng
 * @Last modified time: 2018-10-08 16:09:00
 * @License: jin10
 * @Copyright: jin10
 */
'use strict'

const bodyParser = require('koa-bodyparser')
const logger = require('koa-logger')
const helmet = require('koa-helmet')
const errorHandler = require('./error_handler')

const cors = require('./cors')
const routes = require('./routes')

const Middlewares = app => {
  app.use(logger())
  app.use(errorHandler)
  app.use(helmet())
  app.use(bodyParser({ jsonLimit: '2mb', formLimit: '2mb' }))
  app.use(cors)
  routes(app)
}

module.exports = Middlewares
